package py.org.bor.conteo.business;

import java.util.List;

import javax.inject.Inject;

import org.ticpy.tekoporu.lifecycle.Startup;
import org.ticpy.tekoporu.template.PaginatedDelegateCrud;
import org.ticpy.tekoporu.transaction.Transactional;

import py.org.bor.conteo.domain.Bookmark;
import py.org.bor.conteo.domain.Producto;
import py.org.bor.conteo.persistence.ProductoDAO;

public class ProductoBC extends PaginatedDelegateCrud<Producto, String, ProductoDAO> {
	private static final long serialVersionUID = 1L;
	
	@Inject
	private ProductoDAO productoDAO;
	
	@Startup
	@Transactional
	public void load() {
		if (findAll().isEmpty()) {
			insert(new Producto("111", "111111", "vaso"));
			insert(new Producto("222", "222222", "esponja"));
			insert(new Producto("333", "333333", "La gotita"));
			
		}
	}
	
	public List<Producto> listarProductos(){
		return productoDAO.find(); 
	}
	
	public List<Producto> findPage(int pageSize, int first, String sortField, boolean sortOrderAsc){
		return productoDAO.findPage(pageSize,first, sortField, sortOrderAsc);
	}
	
	public int count() {
		return productoDAO.count();
	}
	
	
}
